package com.renge.eduservice.controller;


import com.renge.commonutils.R;
import com.renge.eduservice.entity.json.SubjectJson;
import com.renge.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-06-02
 */
@Api(description="课程分类管理")
@RestController
@CrossOrigin
@RequestMapping("/eduservice/edu-subject")
public class EduSubjectController {
      @Autowired
      private EduSubjectService eduSubjectService;
      @ApiOperation(value = "添加分类")
      @PostMapping("/add")
      public R addSubject(@ApiParam(name = "file",value = "添加的xlsx表",required = true)
                                        MultipartFile file){
          eduSubjectService.addSubject(file,eduSubjectService);
          return R.ok();
      }
    @ApiOperation(value = "分类列表")
    @PostMapping("/list")
    public R listSubject(){
        List<SubjectJson> subjectJsons = eduSubjectService.getSubjectJsons();
        System.out.print(subjectJsons);
        return R.ok().data("data2",subjectJsons);
    }


}

